package utils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * NOT USED
 * */
public class Room implements Serializable {

	private static final long serialVersionUID = 6065903208758311027L;

	// assumed unique in the context of a theater
	private String name;

	private Integer numRows;

	private Integer numCols;
	// list of unique elements
	private List<Sit> allSits;
	// movie sessions for this room
	private List<MovieSession> allSessions;
	// belongs to what theater
	private Theater t;

	private boolean isFull;

	public Room(String name, int numRows, int numCols,
			List<MovieSession> sessions) {
		this.name = name;
		this.numRows = numRows;
		this.numCols = numCols;
		allSessions = sessions;
	}

	public void setNumRows(int rows) {
		this.numRows = rows;
	}

	public void setNumCols(int numCols) {
		this.numCols = numCols;
	}

	public String getName() {
		return name;
	}

	public Theater getTheater() {
		return t;
	}

	public void setTheater(Theater t) {
		this.t = t;
	}

	public Integer getNumRows() {
		return numRows;
	}

	public Integer getNumCols() {
		return numCols;
	}

	public boolean isFull() {
		return isFull(isFull);
	}

	private boolean isFull(boolean room) {
		//
		return getAllFree().size() == 0;
	}

	public List<Sit> getAllSits() {
		for (int i = 0; i < numRows; i++)
			for (int j = 0; j < numCols; j++) {
				Sit s = new Sit(i + "_" + j);
				s.setOcupied(false);
				allSits.add(s);
			}
		return allSits;
	}

	public List<Sit> getAllFree() {
		List<Sit> freeSits = new ArrayList<Sit>();

		for (Sit s : allSits)
			if (!s.isOccupied()) {
				freeSits.add(s);
			}
		return freeSits;
	}

	public List<Sit> getAllOccupied() {
		List<Sit> occupiedSits = new ArrayList<Sit>();

		for (Sit s : allSits)
			if (s.isOccupied()) {
				occupiedSits.add(s);
			}
		return occupiedSits;
	}
}
